import type {RouteRecordRaw}  from 'vue-router'
import accessEnum from "@/access/AccessEnum";
import AccessEnum from "@/access/AccessEnum";

export const  routes: Array<RouteRecordRaw> = [
  {
    path: '/home',
    name: '主页',
    component: () => import('@/components/ExampleView.vue')
  },
  {
    path: '/question',
    name: '浏览题目',
    component: () => import('@/views/question/QuestionsView.vue')
  },
  {
    path: '/view/question/:id',
    name: '做题页面',
    component: () => import('@/views/question/DoQuestionView.vue'),
    props: true,
    meta: {
      hide: false
    }
  },
  {
    path: '/manage/question',
    name: '管理题目',
    component: () => import('@/views/question/MnaageQuestionView.vue'),
    meta: {
      access: accessEnum.ADMIN
    },
  },
  {
    path: '/add/question',
    name: '创建题目',
    component: () => import('@/views/question/AddQuestionView.vue'),
    meta: {
      access: AccessEnum.ADMIN
    }
  },
  {
    path: '/user',
    name: '用户',
    component: () => import('@/layouts/UserLayout.vue'),
    children: [
      {
        path: '/user/login',
        name: '用户登录',
        component: () => import('@/views/user/UserLogin.vue')
      },
      {
        path: '/user/register',
        name: '用户注册',
        component: () => import('@/views/user/UserRegister.vue')
      }
    ]
  },



  {
    path: '/update/question',
    name: '更新题目',
    component: () => import('@/views/question/AddQuestionView.vue'),
    meta: {
      access: accessEnum.ADMIN,
    },
  },
  {
    path: '/admin',
    component: () => import('@/views/AdminView.vue'),
    name: '管理员',
    meta: {
      access: accessEnum.ADMIN
    },
  },

  {
    path: '/noauth',
    name: '无权限',
    meta: {
      hide: true
    },
    component: () => import('@/views/NoAuthView.vue')
  }
]
